// 基础响应类型
export type BaseResponse<T> = {
    ret: boolean
    msg: string
    data: T
    code?: number
}

// 角色聊天相关类型
export interface ChatMessage {
  id: string
  type: 'user' | 'assistant'
  content: string
  timestamp: number
  isTyping?: boolean
  // 图片相关（可选）：当一次对话需要展示图片时使用
  images?: string[]
  imageLoading?: boolean
  // 错误状态（可选）：标识消息是否为错误消息
  isError?: boolean
}

export interface ChatRequest {
  userInput: string
  chatId: string
  roleId?: string
}

export interface ChatResponse {
  type: 'partial' | 'complete' | 'error' | 'imageStatus' | 'images' | 'audio'
  content: string
  chatId: string
  messageId?: string
  // 当 type === 'imageStatus' 时：
  imageStatus?: {
    imagePrompt?: string
    needImage?: boolean
  }
  // 当 type === 'images' 时：
  images?: string[]
  // 当 type === 'audio' 时：
  audioData?: ArrayBuffer
}

export interface RoleInfo {
  id: number
  name: string
  intro: string
  image: string
  voice: string
  isFavorited: number
  prompt: string
  category: string
  viewCount: number
  isDel: number
  createTime: string | null
  updateTime: string | null
  tags: string | null
  greeting?: string
}

// 角色列表响应类型
export interface RoleListResponse {
  code: number
  data: {
    total: number
    list: RoleInfo[]
    pageNum: number
    pageSize: number
    size: number
    startRow: number
    endRow: number
    pages: number
    prePage: number
    nextPage: number
    isFirstPage: boolean
    isLastPage: boolean
    hasPreviousPage: boolean
    hasNextPage: boolean
    navigatePages: number
    navigatepageNums: number[]
    navigateFirstPage: number
    navigateLastPage: number
  }
  message: string
}

// 角色详情响应类型
export interface RoleDetailResponse {
  code: number
  data: RoleInfo
  message: string
}

// 聊天记录
export interface ChatHistoryItem {
  id: number
  content: string
  chatId: string
  role: string
  isDel: number
  createTime: string
  updateTime: string
  characterId: number
  imageUrl?: string | null
}

export interface ChatHistoryResponse {
  code: number
  data: ChatHistoryItem[]
  message?: string
}

// 创建角色响应类型
export interface CreateRoleResponse {
  code: number
  data: {
    id: number
    name: string
    intro: string
    image: string
    voice: string
    isFavorited: number
    prompt: string
    category: string
    viewCount: number
    isDel: number
    createTime: string | null
    updateTime: string | null
    tags: string[]
    greeting: string
  }
  message: string
}